//--------------------------------------------------------------------------------
// This file is a portion of the D2D1Renderer.  It is distributed
// under the MIT License, available in the root of this distribution and 
// at the following URL:
//
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) Mirco Timmermann
//
//--------------------------------------------------------------------------------
#pragma once

#include <Windows.h>
#include <string>


class Clipboard {
public:
	static inline void CopyToClipboard(std::string text) {
		//copy to clipboard.
		OpenClipboard(0);
		EmptyClipboard();
		const char* output = text.c_str();
		const size_t len = strlen(output) + 1;
		HGLOBAL glob = GlobalAlloc(GMEM_FIXED, len);
		memcpy(glob, output, len);
		SetClipboardData(CF_TEXT, glob);
		CloseClipboard();
		//
	}

	static inline std::string ClipboardToString() {
		std::string text;

		HANDLE clip;
		if(OpenClipboard(NULL)) {
			clip = GetClipboardData(CF_TEXT);
		}

		const char* data = (char*)clip;
		text = data;

		return text;
	}

};